package com.example.controller.order;

import com.example.dto.StorageDTO;
import com.example.feign.StorageFeignClient;
import com.example.model.api.Result;
import com.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("purchase")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private StorageFeignClient storageFeignClient;


    @GetMapping("timeout")
    public Result<String> timeout() {

        storageFeignClient.updateStorage(new StorageDTO(null, "001", 1));
        return new Result<String>().ok("ok");
    }
    @GetMapping
    public Result<String> getOrder() {
        orderService.purchase("123", "001", 1, 1);

        return new Result<String>().ok("ok");
    }
}
